<!--资产列表-->
<template>
	<view class="anchor-console-page">
		<c-layout>
			<c-navigation-bar :title="$t('user.zMoneyList')" />
			<view class="box_content">

				<view class="example-body">
					<uni-datetime-picker @change="handleChange" v-model="dateTime" type="daterange" rangeSeparator="to" />
				</view>

				<view class="date">
					<uni-data-select :default-index="-1" :clear="false" v-model="typeValue" :localdata="typeData"
						@change="changeType"></uni-data-select>
					<u-button style="background-color: #2934D0;color: #fff;width: 200rpx;font-size: 24rpx;" @click="clickSearch">
						{{ $t('addAddress.search') }}
					</u-button>
				</view>


				<scroll-view class="balance-change-list" scroll-y="true">
					<!-- 资金记录列表 -->
					<view class="capital-record-box">
						<scroll-list ref="teamList" :option="queryParams" @refresh="refresh" @load="loadMore">

							<view class="box_item" v-for="(item, index) in teamList.list" :key="index">
								<view class="">
									<view class="text_name" style="color: #111118;font-size: 30rpx;">{{ item.desc }}</view>
									<view class="text_name" style="color: #ccc;font-size: 24rpx;margin-top: 20rpx;">
										{{publicJS.timeZoneSwitching(item.payDate)}}
									</view>

								</view>
								<view class="">
									<view class="text_name" style="color: #F38B3B;font-size: 34rpx">
										${{ item.money.toFixed(2) }}
									</view>
								</view>

							</view>

						</scroll-list>


					</view>
				</scroll-view>


			</view>
		</c-layout>
	</view>
</template>

<script>

	export default {
		components: {},
		data() {
			return {
				showNoDataView: false, //缺省图
				chooseIndex: 0, //0 个人团队 1店铺团队
				dataList: [], //展示列表
				dateTime: [],
				typeValue: "",
				typeData: [],
				// 个人余额
				teamList: {
					isGet: false,
					data: {
						"pageSize": 20,
						"pageNum": 1,

					},
					list: []
				},
			};
		},
		onLoad(option) {
			this.chooseIndex = option.index
			this.initData()
			this.getData();
		
		},
		computed: {

			queryParams() {
				return {
					pageNum: 1,
					size: this.teamList.data.pageSize,
					offsetBottom: 10,
					contentHeight: 0,
					safeArea: true,
					auto: false,
					emptyText: this.$t('system.NoRecord'),
					noMoreText: this.$t('system.NoFurtherDataAvailable'),
					showPullDown: false,
					loadDisabled: false
				}
			},
		},
		methods: {
			initData() {
				if (this.chooseIndex == 0) {
					this.typeData = [{
							value: "",
							text: this.$t("user.allType")
						},
						{
							value: "fu_sg",
							text: this.$t("user.fu_sg")
						},
						{
							value: "pt_spi",
							text: this.$t("user.pt_spi")
						},
						{
							value: "vr",
							text: this.$t("user.vr")
						}
					]
				} else {
					this.typeData = [{
							value: "",
							text: this.$t("user.allType")
						},
						{
							value: "yh_sg",
							text: this.$t("user.yh_sg")
						}
					]
				}
			},
			goBack() {
				// uni.navigateBack(1);
				uni.redirectTo({
					url: '/pages/teamManage/teamManage'
				})
			},
			handleChange() {
				console.log('选择的日期时间：', this.dateTime[0], this.dateTime[1]);
			},
			changeType() {
				console.log('选择的类型：', this.typeValue);
			},
			//点击搜索
			clickSearch() {
				this.getData()
			},
			// //获取数据列表
			// getData() {
			// 	let url
			// 	if (this.chooseIndex == 0) {
			// 		//个人团队资产列表
			// 		url = '/app/userStatisticsTeam/getUserlistIncome'
			// 	} else {
			// 		//店铺团队资产列表
			// 		url = '/app/shopStatisticsTeam/getShoplistIncome'
			// 	}
			// 	this.$u.post(url, {
			// 		code: this.typeValue,
			// 		startTime: this.dateTime[0],
			// 		endTime: this.dateTime[1],
			// 		"pageSize": 10,
			// 		"pageNum": 1,
			// 	}).then(res => {
			// 		console.log('===z', res);
			// 		if (res.data.length > 0) {
			// 			//缺省图
			// 			this.showNoDataView = false
			// 			this.dataList = res.data
			// 		} else {
			// 			//缺省图
			// 			this.showNoDataView = true
			// 		}
			// 	}).catch(err => {
			// 		// 处理异常情况
			// 		console.error("===z" + err);
			// 		this.showNoDataView = true
			// 	});
			// },
			// 获取个人余额
			getData(get = true, more, refresh = 'loadSuccess') {
				let url
				if (this.chooseIndex == 0) {
					//个人团队资产列表
					url = '/app/userStatisticsTeam/getUserlistIncome'
				} else {
					//店铺团队资产列表
					url = '/app/shopStatisticsTeam/getShoplistIncome'
				}
				if(this.dateTime[0]){
					if(this.dateTime[0]==this.dateTime[1]){
						this.teamList.data.startTime = Number(this.publicJS.timeZoneSwitching(this.dateTime[0]+' '+'00:00:00', "x",'UTC'))
							this.teamList.data.endTime = Number(this.publicJS.timeZoneSwitching(this.dateTime[1]+' '+'23:59:59', "x",'UTC'))
					}else{
						this.teamList.data.startTime = Number(this.publicJS.timeZoneSwitching(this.dateTime[0], "x",'UTC'))
							this.teamList.data.endTime = Number(this.publicJS.timeZoneSwitching(this.dateTime[1], "x",'UTC'))
					}
				
				}else{
					this.teamList.data.startTime = ''
						this.teamList.data.endTime = ''
				}
			
					// this.teamList.data.startTime = Number(moment(this.dateTime[0]).tz("America/Los_Angeles").format('x')) ,
					// 	this.teamList.data.endTime =  Number(moment(this.dateTime[1]).tz("America/Los_Angeles").format('x')),
					this.teamList.data.code = this.typeValue,
					this.$u.post(url, this.teamList.data).then(res => {
						this.teamList.isGet = true
						this.teamList.list = more ? [...this.teamList.list, ...res.data.records] : res.data
							.records || []
						this.$refs.teamList[refresh]({
							list: this.teamList.list,
							total: !(res.data.current == res.data.pages) ? this.teamList.list.length + 1 : 0
						});
					}).catch(err => {
						this.$refs.teamList.loadFail()
					})
			},

			loadMore() {
				this.teamList.data.pageNum += 1
				this.getData(false, true)

			},
			refresh(paging) {
				this.teamList.list = []
				this.teamList.data = { pageNum: 1, pageSize: paging.size }
				this.getData(false, false, 'refreshSuccess')


			},
		},
	}
</script>

<style lang="scss" scoped>
	.anchor-console-page {

		.balance-change-list {
			background: #fff;
			flex: 1;
			height: 0;

			.capital-record-box {
				padding: 0 40rpx;
				height: 100%;

				>view {
					margin-bottom: 32rpx;
					height: 100%;
				}
			}
		}

		.box_content {
			display: flex;
			flex-direction: column;
			height: 90vh;

			.box_choice_type {
				display: flex;
				flex-direction: row;
				justify-content: space-between;
			}

			.date {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 20rpx;
				margin-left: 40rpx;
				margin-bottom: 20rpx;

				uni-text {
					width: 90%;
					color: #91909A;
					font-size: 24rpx;
				}

				/deep/ .uni-stat__select {
					flex: unset;
					width: unset;
				}

				/deep/ .uni-select {
					width: 440rpx;
					border: 1px solid #4953ED;

					.uni-select__input-text {
						color: #4953ED;
						font-size: 24rpx;
					}

					.uni-icons {
						color: #4953ED !important;
					}
				}
			}

			/deep/ .example-body {
				width: 670rpx;
				margin-left: 40rpx;
				margin-right: 40rpx;

				.uni-date-x--border {
					border: 0 !important;
				}

				.uni-date-editor--x {
					background: #F6F7FB;
					border-radius: 24rpx 24rpx 24rpx 24rpx;
					padding: 1rpx 20rpx;
					font-size: 24rpx;
				}

				.uni-date__x-input {
					overflow: inherit;
					font-size: 24rpx;
				}

				.uni-date-x {
					background: transparent;
					border-radius: 24rpx 24rpx 24rpx 24rpx;
					opacity: 1;
					font-size: 24rpx;
				}
			}


			.box_item {
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				align-items: center;
				margin: 20rpx 0 40rpx; //上下 左右

				.text_name {
					/* 设置两行省略 */
					text-overflow: -o-ellipsis-lastline;
					overflow: hidden; //溢出内容隐藏
					text-overflow: ellipsis; //文本溢出部分用省略号表示
					display: -webkit-box; //特别显示模式
					-webkit-line-clamp: 1; //行数
					line-clamp: 1;
					-webkit-box-orient: vertical; //盒子中内容竖直排列
					lines: 1;
					/* 设置两行省略 */
				}

			}


		}

	}
</style>